Skip to content

crypto: HPKE (RFC 9180) in public_key_encryption::hpke, with crypto#24 and crypto#26 - #27

Merged
pinhopro merged 10 commits into
mainfrom
crypto/hpke
Dec 4, 2026
Merged

pinhopro merged 10 commits into
mainfrom
crypto/hpke

Conversation

@pinhopro

@pinhopro pinhopro commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Summary

HPKE (RFC 9180) in public_key_encryption::hpke, together with the batch that lands with it in one merge:

  • HPKE: suites as types, the four modes (base, psk, auth, auth_psk), sender and receiver contexts, export_secret, single-shot seal/open, derive_from_seed, the asynchronous forms (refused on the browser backend). Composed from X25519 or P-256, webcpp::hash's HKDF over pieces and AES-GCM or ChaCha20-Poly1305; no heap allocation. Tested against every CFRG vector for these suites (/third_party//hpke, webcpp#66) and against OpenSSL's OSSL_HPKE_* in both directions.
  • crypto#26 (included): dudect_bearssl is printed, not judged, on every WASI target (the owner's decision of 2026-12-04); native lanes, memcheck, MemorySanitizer and the secp256k1/sodium programs keep their verdicts.
  • crypto#24 (included): RFC 9001 Appendix A.1 to A.4 as tests on every AES-GCM backend.
  • Merge resolution: HPKE's key schedule cases join dudect_bearssl and follow the WASI rule; the generated tables regenerated at BearSSL's pin f8a2f3d.
  • Documentation fixes found by the local doc build: @see titles, an undocumented unnamed parameter, ellipses and possessives inside inline code, a code span across a Doc Comment line.

Verification (local, on the combined superproject tree)

  • Native clang (macOS): crypto, hash and codecs tests and examples, all green.
  • dudect_bearssl release, native and wasip2: pass.
  • crypto, hash and codecs documentation builds: green.
  • Tool tests: third_party, crypto and codecs Jamfiles, dudect judge, doc: ok.
  • macOS clang-tidy and the Linux lint in Docker over the touched files: clean.

The full CI runs once on the superproject (webcpp#65) with this merge.

🤖 Generated with Claude Code

R added 10 commits December 4, 2026 00:36
…ion, as tests on OpenSSL, on BearSSL with ctaes for the block and on the defaults, with no QUIC API; the capability table names them
… X25519 or P-256, webcpp::hash's HKDF over pieces and AES-GCM or ChaCha20-Poly1305

The change hpke of webcpporg/proposals (libraries/crypto/openspec/changes/hpke, rulings R1 to
R24): RFC 9180's Hybrid Public Key Encryption with no backend of its own.

- hpke::suite<KeyEncapsulation, KeyDerivation, Cipher[, Backend]> over
  key_encapsulation::x25519_hkdf_sha256 and p256_hkdf_sha256, key_derivation::hkdf_sha256 and
  hkdf_sha512, cipher::aes128_gcm, aes256_gcm, chacha20_poly1305 and export_only, each checked
  by its concept; Backend default_backends, one backend, or backends<KeyBackend, CipherBackend>.
- The mode follows from the arguments: begin_sending and begin_receiving in base, psk, auth and
  auth_psk mode, the single-shot seal and open, and a catch-all per name whose one message lists
  the four argument lists; derive_from_seed (RFC 9180's DeriveKeyPair, X25519's secret kept
  unclamped); sender_context and recipient_context, move-only and wiped, sealing and opening in
  order on an internal 64-bit sequence number, exporting with export_secret<Length> and
  export_secret(purpose, output); the free forms in hpke and the asynchronous forms in async.hpp,
  refused on the browser's backend.
- The labeled HKDF passes "HPKE-v1", the suite identifier, the label and the input as pieces to
  webcpp::hash's HKDF: no input is copied, capped or allocated. A pre-shared key under 32 bytes, an
  empty id and a seed under 32 bytes are refused.
- error::message_limit_reached, the value 21.

Tests: every CFRG vector of these suites (64 entries, four modes, 12,336 encryptions in order,
the exports) on the defaults and with BearSSL's AEADs, on every target; the four modes, refusals,
minimums, the sequence's limit through the seam, and Marmot's recovery-key vectors; OpenSSL's
OSSL_HPKE_* in both directions within its limits, with the same encapsulated key and ciphertexts
for the same ephemeral seed; no allocation, and long inputs (1 MiB info, 64 KiB associated data,
id and purpose) against webcpp::hash's HKDF on the joined labeled inputs; the asynchronous forms;
twelve message tests and their MSVC twins; the timing coverage on libsodium and BearSSL; two
constant-time paths and dudect's key schedule with its A/A control.

The guide's HPKE section with the table of RFC 9180's names, the example hpke_base, crypto.json's
rows and the generated files, the changelog.
The owner's decision of 2026-12-04: under wasmtime the timing of dudect_bearssl's
cases follows the runner's processor (GitHub's AMD EPYC 9V74 read |t| 30 to 150 on
constant_time_equal and 11 to 12 on gcm_seal and ctaes_encrypt), so on a target that
defines __wasi__ the program measures every case once, prints it judged=no with a
line saying why, and passes; the CI's judge measures none of them again. One rule,
case_results made with the reason, replaces base58_decode's wasip2 exception. Native
runs, memcheck, MemorySanitizer, dudect_sodium and dudect_secp256k1 keep their
verdicts. The tables show dudect on wasip2 for BearSSL, ctaes and
secure::constant_time_equal as printed, not judged, with no result
(crypto.json's unjudged_checkers).
# Conflicts:
#	doc/generated/constant-time.adoc
#	doc/generated/namespace-curves.adoc
#	doc/llms.txt
#	doc/tables/crypto.json
…ct_bearssl, printed and not judged on WASI like the rest of it; the tables regenerated at BearSSL's pin f8a2f3d
…h the reference reads as one that does not exist; the guide writes C++ as {cpp}
…possessive inside inline code, no code span across a line of a Doc Comment, the suite-key message reworded
…nline code; llms.txt regenerated from the headers
@pinhopro
pinhopro merged commit 36d1279 into main Dec 4, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant